package com.lemon.boot.common.entity;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

/**
 * @author 李猛
 * @datetime 2024/2/6 23:28
 * @description 登录用户的身份权限信息
 */
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class LoginUserDetail implements UserDetails {
    /**
     * 扩展字段
     */
    private Long userId;//用户ID
    private Long tenantId;//租户ID
    private String name;//姓名
    private List<Long> roleIdList;//角色ID集合

    /**
     * 默认字段
     */
    private String username;//登录名
    private String password;
    private Boolean enabled;
    private Collection<? extends GrantedAuthority> authorities;

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return this.enabled;
    }
}
